package com.example.kotin.myfragment;

import android.view.animation.AlphaAnimation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;

public class AnimationUtils {

    private static int sDuration = 1000;

    public static ScaleAnimation scaleXY() {
        ScaleAnimation animation = new ScaleAnimation(0.5f, 1, 0.5f, 1,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        animation.setDuration(sDuration);
        animation.setInterpolator(new DecelerateInterpolator());//插值器,先快后慢,有多种属性
        return animation;
    }

    public static RotateAnimation rotatXY() {
        RotateAnimation animation = new RotateAnimation(0, 360,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
        animation.setDuration(sDuration);
        animation.setInterpolator(new DecelerateInterpolator());
        return animation;
    }

    public static AlphaAnimation aphlaXY() {
        //透明度
        AlphaAnimation animation = new AlphaAnimation(0, 1);
        animation.setDuration(sDuration);
        animation.setInterpolator(new DecelerateInterpolator());
        return animation;
    }

    public static AnimationSet MultiAnimation() {

        AnimationSet animation = new AnimationSet(false);//动画集合
        animation.addAnimation(scaleXY());
        animation.addAnimation(rotatXY());
        animation.addAnimation(aphlaXY());
        animation.setInterpolator(new DecelerateInterpolator());
        return animation;
    }
}
